URLs are one of the most important features of HTML, because they allow HTML documents to function as hypertext documents. A URL is the address of a file (and possibly a specific location in that file), written in a format that a Web server understands, and which a browser can use to access the file over the Web. An example of a URL is:
http://www.sq.com/doc/tutorial.html
Most of HoTMetaL's commands for working with URLs are in the Links menu.
URLs are contained in certain designated `link' elements. They are attributes of the element, which means that they are values that are associated with the element, but which are not part of the content of the element (that is, text or sub-elements). Each attribute has a name and a value. (These are actually stored inside the start-tag of an element in an HTML file-you can see this if you use a text editor to open the file).
The elements that contain URLs are:
If the mouse pointer is over one of these elements, its URL is displayed in the message area in the lower left corner of the HoTMetaL window.
If the mouse pointer is over one of these elements, its URL is displayed in the message area in the lower left corner of the HoTMetaL window.
URLs can be divided into two groups: complete URLs and relative URLs. A complete URL contains the following parts:
www.sq.com:8888A port number is required if the web server is not running on the default port (that is, 80). This normally occurs only if the site has more than one server running on it.
Consider the example at the beginning of this section:
http://www.sq.com/doc/tutorial.html
Here the scheme is `http', the server address is `www.sq.com', and the path part of the URL is `doc/tutorial.html'.
Note: The path/filename is often omitted in the URL of a site's home page. The server will return the file `index.html' by default. For example, `http://www.sq.com/' is the URL for SoftQuad's home page.
A relative URL will be missing some of this information, and a browser will have to obtain the missing information from the URL of the document that contains the relative URL.
HoTMetaL makes it easy to create and edit URLs, by way of the Edit URL... command in the Links menu.
To use this command you should:
If the current element is A, clicking on the toolbar button is equivalent to choosing the Edit URL... command; similarly, clicking on the toolbar button when the current element is IMG invokes this command.
Edit URL... is disabled if the current element is not one of the ones that can contain a
URL. The Edit URL
dialog box comes up by default when you insert an A element (except when you insert it with the Name Target... command.
Choosing Edit URL... when the current element is
IMG results in slightly different behavior than with other link elements. The first dialog box you see lets you enter information used only for images. If you
click on the [Edit...] button in this dialog box, you will get a dialog that is identical to the
Edit URL
dialog, with one exception, noted below. See the chapter Working with images for more information.
The Edit URL
dialog box contains the following controls for creating
a URL:
Scheme
, containing a list of schemes for
URLs. The scheme describes how the information contained in the
URL is to be used by a browser. Some common
schemes are: Host
text entry box
is for entering a server address, such as a WWW
or
ftp server, or the `domain name' in a mail address.
Port
text entry box
is for entering a port number.Path
text entry box
is for entering the filename (and often a path), or a user name in a mail
address.
Path
text entry box
will bring up a file selection dialog box. This dialog box can be used instead of the
Path
text entry box
when the path component of
the
URL is a file on your system.Name
and
Query
. If you want the URL to be a link to a
specific location, choose Name
and enter the name of the
location in this
text entry box. Do not enter the `#'
character that separates the location name from the rest of the
URL:
HoTMetaL will insert it for you when it creates the URL. (You can
also use the Name Target.../Connect Link command pair to set up a link to a specific location.
See the section Pointing to a specific location for more information.)
Query
is used if you want to specify a query for a searching
program.Note: The dialog box used to edit the URL of of an image (IMG) element does not have the `Name/Query' control group.
HoTMetaL creates a URL with the correct syntax from the information you've entered. Suppose you have entered the following:
Scheme
: http Host
: www.sq.comPath
: orwell/homage.htmlName
: catalunyaFrom this information, HoTMetaL constructs this URL:
http://www.sq.com/orwell/homage.html#catalunya
Notice that HoTMetaL inserts the `/' between the host and the path. Since this scheme specifies that the path starts with a slash, you don't have to type it yourself. In fact, in this case, if you do start the name with a slash, HoTMetaL will ignore it. HoTMetaL also inserted the `#' before `catalunya'.
Note: Certain characters will be converted into an `escape sequence' if they are entered into the Edit URL dialog box. In particular, a tilde (~) will be changed to `%7E', a number sign (#) to `%23', and a space to `%20'. These forms are equivalent to the characters they replace and are interpreted correctly by all browsers.
HoTMetaL lets you maintain a hotlist of frequently used URLs. When you need to insert one of these URLs, you can just pick it from the list instead of having to enter the information over again.
To add the URL you're currently editing to the hotlist:
Edit
URL
dialog box.You'll then see a dialog box that displays the URL and lets you enter a description. This description is how the URL will be displayed in the hotlist dialog box.
To pick a URL from the hotlist:
Edit URL
dialog box. A dialog box will appear, displaying the description of each URL in the hotlist.
To delete a URL from the hotlist:
Edit URL
dialog box. To append a Mosaic hotlist or Netscape bookmarks file to the HoTMetaL hotlist:
Edit URL
dialog box. Creating a URL that points to a specific location in a document is very easy. Here is an example:
http://www.sq.com/authors/orwell/homage.html#madrid
The characters `#madrid' at the end of this URL point to a specific location in the document that the URL refers to. For this link to work:
The quickest way to create the links is to use the Name Target... and Connect Link commands in the Links menu (or the equivalent toolbar buttons).
HoTMetaL gives you a dialog box in which to enter a name for the target link (`madrid' in the example above). If there is a selection when you click on the toolbar button, the first word in the selection will appear in the dialog box by default, but you can enter something else if you want. Link names typically consist of one word, but you can enter more.
HoTMetaL inserts an A element, surrounding the selection if there is one. (This element's NAME attribute will be set to the value you entered.)
HoTMetaL inserts an A element, surrounding the selection if there is one. This element's URL will point to the target link. Since the `path' part of this URL will refer to the local directory containing the document with the target link, you'll have to modify the URL before putting the document on the Web. See the section Moving your files to the web for more information.
You can perform other actions in between creating the two links, but HoTMetaL will remember only the most recent target link that you created with Name Target... (or the equivalent toolbar button).
If it's not convenient to use Connect Link (perhaps you want to enter all the target or source links first) you can use Insert Anchor... or the equivalent toolbar button to create the source links. In this way you can create the links in any order. To create a source link:
HoTMetaL
inserts an A element and brings up the Edit URL
dialog box.
Name
from the
option menu underneath the Path
label (this should be the default).Name
.Use Name Target... in the usual way to create the target links.
The information in URLs has to be arranged in a way that the browsers and servers can understand it-in other words, it has to conform to the correct URL syntax.
Since the Edit URL... command helps you create URLs, you don't usually have to remember the details of the syntax: we've included this information here anyway because we believe that it will help you create URLs if you know what's really going on when you make a URL.
There are actually several URL formats, but fortunately most of the ones you'll have to use fall into two groups.
When you create a link to another HTML document or to an image, you'll usually be specifying a file on a Web server. In this case, the parts must be arranged in the following order:
The URL syntax requires that directory names in the path part of the URL be separated by slashes.
If you're creating this kind of URL with the Edit URL... command, choose the `http' scheme. Then you just need to enter the server address and path/filename: HoTMetaL will construct the URL for you.
If a URL specifies a file on your local system, rather than a file on a Web server, you would write the URL a little differently. You can refer to a file on your local disk only while you're developing and testing your document. When the document is published on the Web, it should refer only to other files available over the Web. See the section Moving your files to the Web for information on how to convert `local' URLs to URLs for the Web.
If you're creating this kind of URL with the Edit URL... command, choose the `file' scheme. Then you just need to enter the path/filename. Notice that you don't need a server address, since your local disk is assumed to be the `server'.
Relative URLs (also called partial URLs) do not contain the complete information required for a browser to locate the file they refer to. For example, the scheme or network address could be missing.
Some of the advantages of using relative URLs over complete URLs are:
The browser has to figure out the missing information, based on the URL of the document that contains the relative URL (this is called the `base URL'). The browser has to construct a complete URL by combining the the relative URL with the relevant information from the base URL.
The base URL can come from one of two sources.
The following guidelines are slightly simplified and don't represent everything that can be said about interpreting relative URLs, but they cover the most frequently encountered cases. Remember that the process being described here is being done `internally' by the browser when it's interpreting the relative URL: the browser doesn't actually modify the URLs in your document.
/orwell/face.gifA file with this URL will be retrieved with the same scheme and from the same server as the document that contains the URL.
orwell/homage.htmand the base URL is:
http://www.sq.com/authors/contents.htmThe browser removes the filename from the base URL to get:
http://www.sq.com/authors/Now the browser appends the relative URL to this to get the complete URL:
http://www.sq.com/authors/orwell/homage.htm
http://www.sq.com/authors/../orwell/homage.htmthen the browser interprets this by removing the directory that precedes those characters from the URL. The resulting URL from the last example would be:
http://www.sq.com/orwell/homage.htmThe directory `authors' has been removed.
If the URL contains the characters `/./' then the browser will simply remove `./' from the resulting URL.
These characters aren't interpreted as special characters unless they occur as the only thing between two slashes (`/../' or `/./'). For example, the sequence `/tom../' just refers to a directory called `tom..'.
If you're creating a relative URL with HoTMetaL's Edit URL... command, leave the Scheme
text entry box blank, and enter the required information in the Path
text entry box.
The mailto scheme is used:
Inside an A or FORM element, as appropriate:
Edit URL
dialog box, choose the `mailto' scheme.Path
text entry box.Host
text entry box.The resulting URL contains the `mailto' scheme, followed a mail address, such as `charles@windsor.org'.
In a form, there is one more thing you have to do in order to use mailto:
Some browsers do not support mailto. Also, in order for this feature to work if your system is behind a firewall, you may need to configure your browser to use the correct proxy server.
By default, HoTMetaL displays the URLs associated with relevant elements in the prefix of the element's start-tag. If you want to hide the URLs, choose Hide URLs from the View menu: the URLs will disappear from the display, and the menu item will toggle to Show URLs. Clicking on Show URLs will cause the URLs to be displayed again.
When the mouse cursor is over an element containing a URL, the URL is displayed in the message area in the lower left corner of the HoTMetaL window.
Before a completed HTML document is moved to a WWW server, all URLs should refer to documents that are available on some WWW server. (While the document is being created, they may refer to documents on your local system.)
For example, when you are creating a document the URLs may consist of local filenames such as:
file:////home/squabble/rodney/orwell/catalonia.html
When the document is placed on your server, you must substitute URLs that refer to documents that are available on your server or some other server. For example:
http://www.sq.com/orwell/catalonia.html
The Publish... command gives you the opportunity to edit all the URLs, modifying them if necessary. This command is a form of `find and replace' for URLs.
When you choose Publish... you will get a dialog box containing two
text entry boxes.
The first box (labeled Change URLs From
) contains a part of the URL that you want to change; the second box (labeled
To
) contains the text that you want to change it to. You can enter text in these boxes to replace the default text.
If there were a large number of URLs for which you needed to change a local directory such as file:////home/squabble/rodney to a server address, such as http://www.sq.com, you could enter:
file:////home/squabble/rodney
in the Change URLs From
text entry box, and:
http://www.sq.com
in the To
text entry box
When you click on the [Find Next] button, HoTMetaL finds the next element that has a URL matching the Change URLs From
text. The insertion point is
placed inside that element, and the document scrolls to its location. The search starts at the insertion point or selection.
Clicking on the [Replace] button will change the text you're searching for to the text in the To
box.
Clicking on the [Replace All] button will make this change for all URLs in the document that contain the Change URLs From
text. This also causes
the dialog box to be dismissed.
This form of `find and replace' matches only starting at the first character of the URL.